package shortcuthelper;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import entry.Entry;

public class ShortcutHelper {

	List<Entry> list = new ArrayList<Entry>();
	Importer importer;
	Exporter exporter;

	public List<Entry> getList() {
		return list;
	}

	public void setImporter(Importer importer) {
		this.importer = importer;
	}

	public void setExporter(Exporter exporter) {
		this.exporter = exporter;
	}

	public void importList(File source) {
		try {
			list = importer.importEntries(source);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void exportList(File target) {
		try {
			exporter.export(list, target);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void addToList(Entry entry) {
		list.add(entry);

	}

	public void addToList(int indexOfEdited, Entry entry) {
		list.set(indexOfEdited, entry);
	}

	public void removeFromList(Entry entry) {
		list.remove(entry);
	}

}
